<template>
	<!-- 抖音投放链接 -->
	<view class="page-body">
		<!-- 页面内容开始 -->

		<!-- 表格搜索组件开始 -->
		<vk-data-table-query v-model="queryForm1.formData" :columns="queryForm1.columns" @search="search">
		</vk-data-table-query>
		<!-- 表格搜索组件结束 -->

		<!-- 自定义按钮区域开始 -->
		<view v-if="showAddBtn">
			<el-row>
				<el-button type="success" size="small" icon="el-icon-circle-plus-outline" @click="addBtn">添加</el-button>
				<el-button type="success" size="small" style="margin-left: 20rpx;" icon="el-icon-circle-plus-outline"
					@click="batchaddBtn">批量添加链接
				</el-button>
				<!-- 批量操作 -->
				<!-- <el-dropdown v-if="table1.multipleSelection" :split-button="false" trigger="click" @command="batchBtn">
					<!-- <el-button type="danger" size="small" style="margin-left: 20rpx;"
						:disabled="table1.multipleSelection.length === 0">
						批量操作<i class="el-icon-arrow-down el-icon--right"></i>
					</el-button> -->
				<!-- <el-dropdown-menu slot="dropdown">
						<el-dropdown-item :command="1">批量设置回传方案</el-dropdown-item>

					</el-dropdown-menu> -->
				<!-- </el-dropdown> -->
			</el-row>
		</view>
		<!-- 自定义按钮区域结束 -->

		<!-- 表格组件开始 -->
		<vk-data-table ref="table1" :action="table1.action" :columns="table1.columns" :query-form-param="queryForm1"
			:right-btns="['detail_auto', 'update', 'delete', 'more']" :right-btns-more="table1.rightBtnsMore"
			:row-no="true" :pagination="true" :data-preprocess="table1.dataPreprocess" @update="updateBtn"
			:selection="true" @delete="deleteBtn" @current-change="currentChange" @selection-change="selectionChange"
			:border="true" :stripe="true">
		</vk-data-table>
		<!-- 表格组件结束 -->

		<!-- 添加或编辑的弹窗开始 -->
		<vk-data-dialog v-model="form1.props.show" :title="form1.props.title" width="700px" mode="form"
			:close-on-click-modal="false" @closed="refresh();">
			<vk-data-form v-model="form1.data" :rules="form1.props.rules" :action="form1.props.action"
				:form-type="form1.props.formType" :columns='form1.props.columns' label-width="160px"
				@success="form1.props.show = false; refresh();"></vk-data-form>
		</vk-data-dialog>
		<!-- 添加或编辑的弹窗结束 -->

		<!-- 批量添加的弹窗开始 -->
		<vk-data-dialog v-model="form3.props.show" :title="form3.props.title" width="700px" mode="form"
			:close-on-click-modal="false" @closed="refresh();">
			<vk-data-form v-model="form3.data" :rules="form3.props.rules" :action="form3.props.action"
				:form-type="form3.props.formType" :columns='form3.props.columns' label-width="160px"
				@success="form3.props.show = false;refresh();">
				<template v-slot:footer="{ loading }">
					<view style="text-align: center;">
						<el-button :loading="loading" type="danger" style="padding: 10px 40px;margin-right: 30px; "
							@click="form3.props.show=false"> 取消
						</el-button>
						<el-button :loading="loading" type="success" style="padding: 10px 40px; "
							@click="batchAdd(form3.data)"> 确定
						</el-button>
					</view>
				</template>
			</vk-data-form>
		</vk-data-dialog>
		<!-- 批量添加的弹窗结束 -->

		<el-dialog title="剧付费卡点" :visible.sync="dialogVisible5" width="700px" :destroy-on-close="true" :center="true"
			:close-on-click-modal="false">
			<el-alert
				:title="'当前账户的用户名：' + vk.vuex.get('$user.userInfo.username') + ' , 当前账户的代理商ID：' + vk.vuex.get('$user.userInfo._id')"
				type="error" :closable="false">
			</el-alert>
			<el-alert :title="'当前投放链接id：' + this.tfid + ' , 当前剧名：' + this.tv_name" type="success" :closable="false">
			</el-alert>

			<el-input placeholder="请设置付费集数" v-model="setting.tf_start_needpay" type="text">
				<template slot="prepend">设置付费集数</template>
			</el-input>
			<el-input placeholder="请设置付费豆数" v-model="setting.tf_pay_bean" type="text">
				<template slot="prepend">设置付费豆数</template>
			</el-input>
			<view style="padding: 2% 20%;">
				<el-button type="primary" @click="saveSetting">保存</el-button>
			</view>
		</el-dialog>
		<!-- 回传方案设置 -->
		<vk-data-dialog v-model="form2.props.show" :title="form2.props.title" width="1300px" mode="form"
			:close-on-click-modal="false">
			<vk-data-form v-model="form2.data" :rules="form2.props.rules" :action="form2.props.action"
				:form-type="form2.props.formType" :columns="form2.props.columns" label-width="80px"
				:submit-disabled="true">
				<!-- 其他配置 -->
				<template v-slot:hour_backhaul="{ form, keyName }">
					<view style="display: flex; align-items: center;">
						<!-- 输入框 -->
						<input v-model="form[keyName]" type="number" placeholder="输入小时">
						<!-- 标题 -->
						<text style="margin-left: 10px;">小时内订单回传</text>
					</view>
				</template>
			</vk-data-form>
		</vk-data-dialog>

		<el-dialog title="监测链接复制" :visible.sync="dialogVisible4" width="700px" :before-close="handleClose4"
			:destroy-on-close="true" :center="true" :close-on-click-modal="false">

			<el-button type="success" size="small" @click="douyin">抖音监测链接</el-button>

			<el-button type="success" size="small" @click="kuaishou">快手监测链接</el-button>

			<el-button type="success" size="small" @click="tengxun">腾讯监测链接</el-button>
			<el-button type="success" size="small" @click="baidu">百度监测链接</el-button>
		</el-dialog>

		<!-- 弹窗投放链接今日实时数据开始 -->
		<el-dialog title="投放链接数据预览" :visible.sync="dialogVisible1" width="70%" :before-close="handleClose"
			:destroy-on-close="true" :center="true" :close-on-click-modal="false">
			<view>
				<view style="margin: 20px 0 0 20px;font-size: 40rpx;font-weight: bold;">当前在线人数 {{ dqzxrs }} 人</view>
				<view style="margin: 0 0 0 20px;font-size: 40rpx;font-weight: bold;">{{ radio1 }}</view>
				<el-radio-group v-model="radio1" size="medium" @change="timechange"
					style="margin-left: 30rpx;margin-top: 10rpx;">
					<el-radio-button label="今日数据"></el-radio-button>
					<el-radio-button label="昨日数据"></el-radio-button>
					<el-radio-button label="3天总数据"></el-radio-button>
					<el-radio-button label="7天总数据"></el-radio-button>
					<el-radio-button label="15天总数据"></el-radio-button>
					<el-radio-button label="本月"></el-radio-button>
					<el-radio-button label="上个月"></el-radio-button>
				</el-radio-group>
				<el-date-picker v-model="value2" type="daterange" align="right" unlink-panels range-separator="至"
					start-placeholder="开始日期" end-placeholder="结束日期" :picker-options="pickerOptions" :change="change()"
					style="margin-left: 20rpx;">
				</el-date-picker>
				<view style="margin: 0 15px;">
					<view style="display: flex;flex-wrap: wrap;">
						<view class="topbox">
							<text style="color: gray;">新增用户数
								<el-tooltip class="item" effect="dark" content="今日新增的人数" placement="top-end">
									<i style="margin-left: 30rpx;" class="vk-icon-question"></i>
								</el-tooltip>
							</text>
							<view class="numstyle">{{ new_add_user || 0 }}</view>
						</view>
						<view class="topbox">
							<text style="color: gray;">新用户充值金额
								<el-tooltip class="item" effect="dark" content="今日新增用户付费的金额" placement="top-end">
									<i style="margin-left: 30rpx;" class="vk-icon-question"></i>
								</el-tooltip>
							</text>
							<view class="numstyle">¥{{ new_users_moneysum || 0 }}</view>
						</view>
						<view class="topbox">
							<text style="color: gray;">新用户充值人数
								<el-tooltip class="item" effect="dark" content="今日新增用户中付费的人数" placement="top-end">
									<i style="margin-left: 30rpx;" class="vk-icon-question"></i>
								</el-tooltip>
							</text>
							<view class="numstyle">{{ newUsers_payNumber || 0 }}</view>

						</view>
						<view class="topbox">
							<text style="color: gray;">新用户付费率
								<el-tooltip class="item" effect="dark" content="新用户充值人数/新增用户" placement="top-end">
									<i style="margin-left: 30rpx;" class="vk-icon-question"></i>
								</el-tooltip>
							</text>
							<view class="numstyle">{{ newUsers_rate || 0 }}%</view>

						</view>
						<view class="topbox">
							<text style="color: gray;">新用户人均充值
								<el-tooltip class="item" effect="dark" content="新用户充值金额/新增用户数" placement="top-end">
									<i style="margin-left: 30rpx;" class="vk-icon-question"></i>
								</el-tooltip>
							</text>
							<view class="numstyle">￥{{ newUsers_pcr || 0 }}</view>
						</view>
						<view class="topbox">
							<view style="color: gray;">充值金额</view>
							<view class="numstyle">¥{{ today_Recharge_amount || 0 }}</view>
						</view>
						<view class="topbox">
							<text style="color: gray;">充值笔数</text>
							<view class="numstyle">
								{{ today_recharges_Number || 0 }}
							</view>
						</view>
						<view class="topbox">
							<text style="color: gray;">笔单价
								<el-tooltip class="item" effect="dark" content="充值金额/充值笔数" placement="top-end">
									<i style="margin-left: 30rpx;" class="vk-icon-question"></i>
								</el-tooltip>
							</text>
							<view class="numstyle">
								{{ today_unit_price || 0 }}
							</view>
						</view>

					</view>
				</view>
			</view>

			<span slot="footer" class="dialog-footer">
				<el-button @click="dialogVisible1 = false">关 闭</el-button>
			</span>
		</el-dialog>
		<!-- 弹窗投放链接今日实时数据结束 -->
		<!-- 弹窗投放链接每日数据开始 -->
		<el-dialog title="投放链接数据预览" :visible.sync="dialogVisible6" width="70%" :before-close="handleClose6"
			:destroy-on-close="true" :center="true" :close-on-click-modal="false">
			<view>
				<el-table :data="tableData" style="width: 100%">
					<el-table-column prop="date" label="日期">
					</el-table-column>
					<el-table-column prop="drxh" label="当日消耗">
					</el-table-column>
					<el-table-column prop="drcz" label="当日充值">
					</el-table-column>
					<el-table-column prop="jrroi" label="今日ROI">
					</el-table-column>
					<el-table-column prop="gzcb" label="关注成本" width="180">
					</el-table-column>
					<el-table-column prop="xyhffcb" label="新用户付费成本" width="180">
					</el-table-column>
					<el-table-column prop="xyhffl" label="新用户付费率" width="180">
					</el-table-column>
					<el-table-column prop="xyhs" label="新用户数" width="180">
					</el-table-column>
					<el-table-column prop="xyhczje" label="新用户充值金额" width="180">
					</el-table-column>
					<el-table-column prop="xyhczrs" label="新用户充值人数" width="180">
					</el-table-column>
					<el-table-column prop="drczbs" label="当日充值笔数" width="180">
					</el-table-column>
					<el-table-column prop="hcbs" label="回传笔数" width="180">
					</el-table-column>
					<el-table-column prop="ad_id" label="广告账户ID" width="180">
					</el-table-column>
				</el-table>
			</view>
			<span slot="footer" class="dialog-footer">
				<el-button @click="dialogVisible6 = false">关 闭</el-button>
			</span>
		</el-dialog>
		<!-- 弹窗投放链接每日数据结束 -->
		<!-- 预览充值面板开始页面-->
		<el-dialog title="预览充值面板页面" :visible.sync="dialogVisible9" width="500px" :before-close="handleClose9"
			:destroy-on-close="true" :center="true" :close-on-click-modal="false">
			<view class="boxTemplate">
				<view v-for="(item, index) in this.preview_recharge_plan" :key="index"
					style="margin-left: 10rpx; position: relative">
					<image v-if="item.showFinger" class="floating-image" src="../../static/finger.jpg"></image>
					<!-- @click="createOrder(item,index)" -->
					<view class="Scheme">
						<view class="Schemecontentss"
							v-if="item.subject == '月度会员' || item.subject == '季度会员' || item.subject == '年度会员'">
							<view class="Judge">
								{{ item.judge_text ? item.judge_text : item.subject }}
							</view>
							<view class="RechargeAmount">￥{{ item.recharge_amount / 100 }}</view>
							<view class="RechargeText">{{ item.recharge_text }}</view>
						</view>
						<view class="Schemecontentss" v-else-if="item.subject == '单剧会员'">
							<view class="Judge">
								{{ item.judge_text ? item.judge_text : "解锁全集" }}
							</view>
							<view class="RechargeAmount">￥{{ item.recharge_amount / 100 }}</view>
							<view class="RechargeText">{{ item.recharge_text }}</view>
						</view>
						<view class="Schemecontentss" v-else-if="item.subject == '自定义会员'">
							<view class="Judge">
								{{ item.judge_text ? item.judge_text : "VIP会员" }}
							</view>
							<view class="RechargeAmount">￥{{ item.recharge_amount / 100 }}</view>
							<view class="RechargeText">{{ item.recharge_text }}</view>
						</view>
						<view class="Schemecontent" v-else-if="item.judge == true">
							<view class="Judge">{{ item.judge_text }}</view>
							<view class="RechargeAmount">￥{{ item.recharge_amount / 100 }}</view>
							<view class="GiveBean" v-if="item.give_bean">{{ item.give_bean }}</view>
							<view class="RechargeText">{{ item.recharge_text }}</view>
							<view class="PercentageUser">{{ item.percentage_user || 99 }}%的用户选择</view>
						</view>

						<view class="Schemecontent" v-else-if="item.judge == false">
							<view class="Judge">{{ item.subject }}</view>
							<view class="RechargeAmount">￥{{ item.recharge_amount / 100 }}</view>
							<view class="GiveBean" v-if="item.give_bean">{{ item.give_bean }}</view>
							<view class="RechargeText">{{ item.recharge_text }}</view>
						</view>
					</view>
				</view>
			</view>


			<span slot="footer" class="dialog-footer">
				<el-button @click="dialogVisible9 = false">关 闭</el-button>
			</span>
		</el-dialog>
		<!-- 预览充值面板结束页面 -->
		<!-- 页面内容结束 -->
	</view>
</template>

<script>
	var that; // 当前页面对象
	var vk = uni.vk; // vk实例
	var originalForms = {}; // 表单初始化数据
	const db = uniCloud.database();
	export default {
		data() {
			// 页面数据变量
			return {
				dramaId: null,
				todayStart: 0,
				pickerOptions: {
					shortcuts: [{
						text: '最近一周',
						onClick(picker) {
							const end = new Date();
							const start = new Date();
							start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
							picker.$emit('pick', [start, end]);
						}
					}, {
						text: '最近一个月',
						onClick(picker) {
							const end = new Date();
							const start = new Date();
							start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
							picker.$emit('pick', [start, end]);
						}
					}, {
						text: '最近三个月',
						onClick(picker) {
							const end = new Date();
							const start = new Date();
							start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
							picker.$emit('pick', [start, end]);
						}
					}]
				},
				value2: '',
				tjsj_item: {},
				radio1: "今日数据",
				//投放链接每日数据相关
				dialogVisible6: false,
				//投放链接每日数据
				tableData: [],
				preview_recharge_plan: [],
				setting: {
					tf_start_needpay: "",
					tf_pay_bean: ""
				},
				tfid: 0, //临时存放
				invite_code: 0, //临时存放
				tv_name: "", //临时存放
				tv_id: "", //临时存放
				cloudfunction_path: "",
				dialogVisible: false,
				dialogVisible2: false,
				dialogVisible3: false,
				dialogVisible4: false,
				dialogVisible5: false,
				dialogVisible9: false,
				//投放链接今日数据相关
				dialogVisible1: false,
				new_add_user: 0, //新增用户
				new_users_moneysum: 0, //新用户充值金额
				newUsers_payNumber: 0, //新用户充值人数
				newUsers_rate: 0, //新用户付费率
				newUsers_pcr: 0, //新用户人均充值金额
				today_Recharge_amount: 0, //今日充值金额
				today_recharges_Number: 0, //今日充值笔数
				today_unit_price: 0, //笔单价
				dqzxrs: 0, //当前在线人数

				showAddBtn: true,
				domain: uni.getStorageSync("domain"),
				// 页面是否请求中或加载中
				loading: false,
				// init请求返回的数据
				data: {

				},
				// 表格相关开始 -----------------------------------------------------------
				table1: {
					rightBtnsMore: [{
							title: '设置剧付费卡点',
							disabled: (item) => {
								//控制该按钮对哪些数据生效
								// return item._id == '63c54f03819ce8640cced33f'
							},
							onClick: (item) => {
								that = this;
								this.dialogVisible5 = true;
								this.tfid = item._id; //把tfid固定到本地
								this.agentId = item.agentId; //把代理商邀请码固定到本地
								this.tv_name = item.tv_name; //把剧名固定到本地
								this.tv_id = item.tv_id; //把剧id固定到本地
								this.setting.tf_start_needpay = "";
								this.setting.tf_pay_bean = "";
								vk.callFunction({
									url: 'admin/dls/kh/settingTV/tfljList',
									title: '请求中...',
									data: {
										tfid: that.tfid
									},
									success: (data) => {
										that.setting.tf_start_needpay = data.settingTV.data[0]
											.agent_series;
										that.setting.tf_pay_bean = data.settingTV.data[0].agent_pay;
									}
								});
								// console.log(item);
							}
						},
						{
							title: '预览回传方案',
							disabled: (item) => {
								//控制该按钮对哪些数据生效
								// return item._id == '63c54f03819ce8640cced33f'
							},
							onClick: (item) => {
								this.preview(item)
								// console.log(this.huichuan);
							}
						}, {
							title: '监测链接',
							disabled: (item) => {
								//控制该按钮对哪些数据生效
								// return item._id == '63c54f03819ce8640cced33f'
							},
							onClick: (item) => {
								console.log("item=", item);
								this.tfid = item._id; //把tfid固定到本地
								this.invite_code = item.agentId; //把代理商邀请码固定到本地
								this.dialogVisible4 = true;
							}
						},
						{
							title: '统计数据',
							disabled: (item) => {

							},
							onClick: (item) => {
								this.tjsj_item = item
								console.log("this.tjsj_item===", this.tjsj_item);
								let start_time = this.todayStart
								let end_time = this.todayStart + 86400000
								this.get_today_number(start_time, end_time, item)
								this.dialogVisible1 = true;

							}
						},
						{
							title: '预览首充充值方案',
							disabled: (item) => {
								//控制该按钮对哪些数据生效
								// return item._id == '63c54f03819ce8640cced33f'
							},
							onClick: async (item) => {
								console.log("item=", item);
								let info = await db.collection('a_czmb').doc(item.setting_czmb).get();
								console.log("info", info.result.data);
								this.preview_recharge_plan = info.result.data[0].bind_recharge
								this.dialogVisible9 = true;
							}
						},
						{
							title: '预览非首充充值方案',
							disabled: (item) => {
								//控制该按钮对哪些数据生效
								// return item._id == '63c54f03819ce8640cced33f'
							},
							onClick: async (item) => {
								console.log("item=", item);
								let info = await db.collection('a_czmb').doc(item.setting_again_czmb).get();
								console.log("info", info.result.data);
								this.preview_recharge_plan = info.result.data[0].bind_recharge
								this.dialogVisible9 = true;
							}
						},
						{
							title: '每日数据',
							disabled: (item) => {},
							onClick: (item) => {
								vk.callFunction({
									url: 'admin/dls/kh/dytflj/get_meiri_data',
									title: '请求中...',
									data: {
										item
									},
									success: (data) => {
										this.dialogVisible6 = true;
										this.tableData = data.rows
										console.log(this.tableData)
									}
								});
							}
						},
					],
					dataPreprocess: (list) => {
						// 这里写自己的处理逻辑，最终返回处理完的list即可。
						// list.map((item, index) => {
						// 	item.tfurl = "https://www.xxxx.com/a.html?tfid=" + item._id;
						// });
						return list;
					},
					// 表格数据请求地址
					action: "admin/dls/kh/dytflj/getList",
					// 表格字段显示规则
					columns: [{
							key: "",
							title: "广告ID/描述",
							type: "group",
							minWidth: 150,
							align: "left",
							columns: [{
									"key": "ad_id",
									"title": "广告ID",
									"type": "text",
								},
								{
									"key": "desc",
									"title": "描述",
									"type": "text",
								}
							],
						},

						{
							key: "",
							title: "推广链接/小程序路径",
							type: "group",
							minWidth: 500,
							align: "left",
							columns: [{
									"key": "tfurl",
									"title": "投放路径",
									"type": "text",
								},
								{
									"key": "xcxpath",
									"title": "小程序path",
									"type": "text",
								},
								{
									"key": "_id",
									"title": "投放链接id",
									"type": "text",
									"width": 220,
								},
							],
						},
						{
							key: "",
							title: "绑定小程序",
							type: "group",
							minWidth: 220,
							align: "left",
							columns: [{
									key: "appid",
									title: "appid",
									type: "text",
									defaultValue: "未绑定"
								},
								{
									key: "appname",
									title: "小程序名称",
									type: "text",
									defaultValue: "未绑定"
								},
							],
						},
						{
							key: "",
							title: "剧集信息",
							type: "group",
							minWidth: 160,
							align: "left",
							columns: [{
									"key": "tv_name",
									"title": "剧名",
									"type": "text",
								},
								{
									"key": "series",
									"title": "第几集",
									"type": "text",
								},
								{
									"key": "path",
									"title": "页面路径",
									"type": "text"
								}
							],
						}

					],
					// 多选框选中的值
					multipleSelection: [],
					// 当前高亮的记录
					selectItem: ""
				},
				// 表格相关结束 -----------------------------------------------------------
				// 表单相关开始 -----------------------------------------------------------
				// 查询表单请求数据
				queryForm1: {
					// 查询表单数据源，可在此设置默认值
					formData: {

					},
					// 查询表单的字段规则 fieldName:指定数据库字段名,不填默认等于key
					columns: [{
							"key": "ad_id",
							"title": "广告ID",
							"type": "text",
							"mode": "="
						},
						{
							"key": "desc",
							"title": "描述",
							"type": "text",
							"mode": "%%"
						},
						{
							"key": "appid",
							"title": "选择小程序",
							"type": "select",
							"width": 200,
							"data": uni.getStorageSync("appid_ARR"),
							"mode": "="
						},
						{
							"key": "_id",
							"title": "投放链接id",
							"type": "text",
							"width": 150,
							"mode": "="
						},
					]
				},
				form1: {
					// 表单请求数据，此处可以设置默认值
					data: {
						series: 1,
						follow: 0,
						recharge_amount: [],
						domain: uni.getStorageSync("domain"),
						appid: vk.vuex.get('$user.userInfo.appid') || "未绑定小程序",
						appname: vk.vuex.get('$user.userInfo.appname') || "未绑定小程序",
						bind_first_recharge_id: [],
						bind_first_recharge: [],
						bind_again_recharge_id: [],
						bind_again_recharge: [],
					},
					// 表单属性
					props: {
						// 表单请求地址
						action: "",
						// 表单字段显示规则
						columns: [{
								"key": "ad_id",
								"title": "广告ID",
								"type": "text",
								"tips": "广告账户ID（仅做标记，无实际作用，可不填）"
							},
							{
								"key": "desc",
								"title": "描述",
								"type": "text"
							},
							{
								key: "backup",
								title: "选择配置回传项",
								type: "table-select",
								placeholder: "选择",
								action: "admin/dls/kh/configBackup/getList",
								columns: [{
										key: "adPlatform",
										title: "广告平台",
										type: "text",
										nameKey: true
									},
									{
										key: "_id",
										title: "回传配置id",
										type: "text",
										idKey: true
									},
									{
										key: "remark",
										title: "备注",
										type: "text"
									}, //备注
								]
							},
							{
								key: "tv_id",
								title: "选主剧",
								type: "table-select",
								placeholder: "选择",
								action: "admin/pages/kh/dsjzxgl/dsj/getList",
								columns: [{
										key: "tv_name",
										title: "剧名",
										type: "text",
										nameKey: true
									},
									{
										key: "sub_tvname",
										title: "副剧名",
										type: "text"
									},
									{
										key: "_id",
										title: "剧id",
										type: "text",
										width: 260,
										idKey: true
									},
									{
										key: "tv_image",
										title: "封面图",
										type: "image"
									},
								],

								watch: (res) => {
									// console.log("watch", res.option),
									this.form1.data.tv_name = res.option.tv_name
								}
							},
							{
								key: "setting_czmb",
								title: "充值模版选择(首充)",
								type: "table-select",
								placeholder: "选择",
								action: "admin/pages/kh/yhsj/czmb/getList",
								columns: [{
										"key": "subject",
										"title": "分类",
										"type": "text",
										nameKey: true,
									},
									{
										key: "appname",
										title: "小程序名称",
										type: "text",
										defaultValue: "未绑定"
									},
									{
										key: "nickname",
										title: "代理商昵称",
										type: "text",
										defaultValue: ""
									},
									{
										key: "_id",
										title: "id",
										type: "text",
										idKey: true,
										width: 1
									},
								],
								multiple: false,
								watch: (res) => {
									console.log("res.option", res.option);
									this.form1.data.setting_czmb = res.option._id
								}
							},
							{
								key: "setting_again_czmb",
								title: "充值模版选择(复充)",
								type: "table-select",
								placeholder: "选择",
								action: "admin/pages/kh/yhsj/czmb/getList",
								columns: [{
										"key": "subject",
										"title": "分类",
										"type": "text",
										nameKey: true,
									},
									{
										key: "appname",
										title: "小程序名称",
										type: "text",
										defaultValue: "未绑定"
									},
									{
										key: "nickname",
										title: "代理商昵称",
										type: "text",
										defaultValue: ""
									},
									{
										key: "_id",
										title: "id",
										type: "text",
										idKey: true,
										width: 1
									},
								],
								multiple: false,
								watch: (res) => {
									console.log("res.option", res.option);
									this.form1.data.setting_again_czmb = res.option._id
								}
							},
							{
								"key": "tv_name",
								"title": "剧名",
								"type": "text",
								"disabled": true
							},
							{
								"key": "series",
								"title": "第几集",
								"type": "text",
								"tips": "跳转到哪一集开始播放，一般是第一集"
							},
							{
								key: "appid",
								title: "小程序appid",
								type: "table-select",
								placeholder: "选择",
								action: "admin/pages/kh/xcxpz/xcxgl/getList",
								columns: [{
										key: "appid",
										title: "appid",
										type: "text",
										idKey: true
									},
									{
										key: "appname",
										title: "小程序名字",
										type: "text",
										nameKey: true,
									}
								],
								watch: (res) => {
									this._data.form1.data.appid = res.option.appid;
									this._data.form1.data.appname = res.option.appname;
								}
							},
							{
								key: "appname",
								title: "小程序名字",
								placeholder: "请点击上方选择",
								type: "text",
								disabled: true
							},
							{
								"key": "domain",
								"title": "网页地址",
								"type": "text",
								"disabled": true
							}
							// {
							// 	"key": "follow",
							// 	"title": "是否需要关注",
							// 	"type": "select",
							// 	data: [{
							// 			value: 0,
							// 			label: "不需要关注"
							// 		},
							// 		{
							// 			value: 1,
							// 			label: "关注公众号"
							// 		},
							// 		{
							// 			value: 2,
							// 			label: "关注企业微信"
							// 		}
							// 	]
							// },
							// {
							// 	"key": "gzhId",
							// 	"title": "授权公众号",
							// 	"type": "text"
							// },
							// {"key":"platform","title":"平台","type":"text","width":200}
						],
						// 表单验证规则
						rules: {
							tv_id: [{
								required: true,
								message: "请选择主剧",
								trigger: ['blur', 'change']
							}],
							series: [{
								required: true,
								message: "请输入集数",
								trigger: ['blur', 'change']
							}],
							appid: [{
								required: true,
								message: "请输入正确的appid,否则跳转会出错",
								trigger: ['blur', 'change']
							}],
						},
						// add 代表添加 update 代表修改
						formType: "",
						// 是否显示表单的弹窗
						show: false
					}
				},
				form2: {
					// 表单请求数据，此处可以设置默认值
					data: {
						//先回传的笔数
						firstOrderNumber: 10,
						remark: '', // 备注
						// hour_backhaul: 24, // 小时回传
						adPlatform: '', // 广告平台
						transmitOrders: false, // 是否回传当日新用户订单
						firstOrder: false, // 是否回传首笔订单
						backup: [],
						//价格区间
						douyinUrl: '', // 抖音URL
						douyinToken: '', // 抖音Token
						baiduToken: '', // 百度Token
					},
					// 表单属性
					props: {
						// 表单请求地址
						action: '',
						// 表单字段显示规则
						columns: [{
								disabled: true,
								key: 'adPlatform',
								title: '广告平台',
								type: 'select',
								width: 200,
								data: [{
										label: '抖音',
										value: 'douyin'
									},
									{
										label: '腾讯',
										value: 'tencent'
									},
									{
										label: '快手',
										value: 'kuaishou'
									},
									{
										label: '百度',
										value: 'baidu'
									},



								]
							},
							// { "key": "hour_backhaul", "title": "小时回传", "type": "number", "width": 200 },
							{
								disabled: true,

								key: 'transmitOrders',
								title: '是否回传当日新用户订单',
								type: 'switch',
								labelWidth: 180
							},
							{
								disabled: true,
								key: 'hour_backhaul',
								title: '设置用户注册',
								labelWidth: 100,
								type: 'number',
								showRule: (formData) => {
									if (formData.transmitOrders == true) {
										return false;
									}
								}
							},
							{
								disabled: true,
								key: 'firstOrder',
								title: '是否回传首笔订单',
								type: 'switch',
								labelWidth: 140
							},
							{
								disabled: true,
								key: 'firstOrderNumber',
								title: '先固定回传笔数',
								type: 'number',
								labelWidth: 130
							},

							{
								disabled: true,
								key: 'backup',
								title: '',
								type: 'array<object>',
								itemWidth: 120,
								showAdd: true,
								showClear: true,
								// 新增一行时,该行的默认值
								defaultValue: {
									switch: true,
									text1: ''
								},
								rightBtns: ['delete'],
								// 每行每个字段对应的渲染规则
								columns: [{
										disabled: true,

										key: 'minAmount',
										title: '最低价格',
										type: 'money',
										rules: [{
											required: true,
											message: '该项不能为空',
											trigger: ['change', 'blur']
										}]
									},
									{
										disabled: true,

										key: 'maxAmount',
										title: '最高价格',
										type: 'money',
										rules: [{
											required: true,
											message: '该项不能为空',
											trigger: ['change', 'blur']
										}]
									},
									{
										disabled: true,

										key: 'proportion_value',
										title: '',
										type: 'number',
										defaultValue: 0,
										showRule: (formData) => {
											return false;
										}
									},
									{
										disabled: true,

										key: 'reportCount',
										title: '满',
										type: 'number',
										rules: [],
										disabled: (formData) => {
											if (formData.isBackhaul != 3) {
												return true;
											} else {
												return false;
											}
										}
									},
									{
										disabled: true,

										key: 'skipCount',
										title: '漏',
										type: 'number',
										rules: [],
										disabled: (formData) => {
											if (formData.isBackhaul != 3) {
												return true;
											} else {
												return false;
											}
										}
									},
									{
										disabled: true,

										key: 'isBackhaul',
										title: '设置上报模式',
										type: 'radio',
										defaultValue: 3,
										data: [{
												value: 1,
												label: '全部上报'
											},
											{
												value: 2,
												label: '全部不上报'
											},
											{
												value: 3,
												label: '自定义'
											}
										]
									}
								]
							},
							{
								disabled: true,
								key: 'douyinUrl',
								title: '抖音URL',
								type: 'text',
								width: 200,
								showRule: 'adPlatform == douyin'
							}, // 默认隐藏
							{
								disabled: true,
								key: 'douyinToken',
								title: '抖音Token',
								type: 'text',
								width: 200,
								showRule: 'adPlatform == douyin'
							}, // 默认隐藏
							{
								disabled: true,
								key: 'baiduToken',
								title: '百度Token',
								type: 'text',
								width: 200,
								showRule: 'adPlatform == baidu'
							}, // 默认隐藏// 默认隐藏
							{
								disabled: true,

								key: 'remark',
								title: '备注',
								type: 'text',
								width: 200
							} // 默认隐藏
							// ...
						],
						// 表单验证规则
						rules: {},
						// add 代表添加 update 代表修改
						formType: '',
						// 是否显示表单的弹窗
						show: false
					}
				},
				form3: {
					// 表单请求数据，此处可以设置默认值
					data: {
						num: 0,
						series: 1,
						recharge_amount: [],
						tv_id: "",
						tv_name: "",
						domain: uni.getStorageSync("domain"),
						appid: vk.vuex.get('$user.userInfo.appid') || "未绑定小程序",
						appname: vk.vuex.get('$user.userInfo.appname') || "未绑定小程序"
					},
					// 表单属性
					props: {
						// 表单请求地址
						action: "",
						// 表单字段显示规则
						columns: [{
								"key": "num",
								"title": "添加几条投放链接",
								"type": "number",
								"tips": "添加几条投放链接"
							}, {
								"key": "ad_id",
								"title": "广告ID",
								"type": "text",
								"tips": "广告账户ID（仅做标记，无实际作用，可不填）"
							},
							{
								"key": "desc",
								"title": "描述",
								"type": "text"
							},
							{
								key: "backup",
								title: "选择配置回传项",
								type: "table-select",
								placeholder: "选择",
								action: "admin/dls/kh/configBackup/getList",
								columns: [{
										key: "adPlatform",
										title: "广告平台",
										type: "text",
										nameKey: true
									},
									{
										key: "_id",
										title: "回传配置id",
										type: "text",
										idKey: true
									},
									{
										key: "remark",
										title: "备注",
										type: "text"
									}, //备注
								]
							},
							{
								key: "tv_id",
								title: "选主剧",
								type: "table-select",
								placeholder: "选择",
								action: "admin/pages/kh/dsjzxgl/dsj/getList",
								columns: [{
										key: "tv_name",
										title: "剧名",
										type: "text",
										nameKey: true
									},
									{
										key: "sub_tvname",
										title: "副剧名",
										type: "text"
									},
									{
										key: "_id",
										title: "剧id",
										type: "text",
										width: 260,
										idKey: true
									},
									{
										key: "tv_image",
										title: "封面图",
										type: "image"
									}
								],
								watch: (res) => {
									// console.log("watch", res.option),
									this.form3.data.tv_name = res.option.tv_name
								}
							},
							{
								key: "setting_czmb",
								title: "充值模版选择(首充)",
								type: "table-select",
								placeholder: "选择",
								action: "admin/pages/kh/yhsj/czmb/getList",
								columns: [{
										"key": "subject",
										"title": "分类",
										"type": "text",
										nameKey: true,
									},
									{
										key: "appname",
										title: "小程序名称",
										type: "text",
										defaultValue: "未绑定"
									},
									{
										key: "nickname",
										title: "代理商昵称",
										type: "text",
										defaultValue: ""
									},
									{
										key: "_id",
										title: "id",
										type: "text",
										idKey: true,
										width: 1
									},
								],
								multiple: false,
								watch: (res) => {
									console.log("res.option", res.option);
									this.form3.data.setting_czmb = res.option._id
								}
							},
							{
								key: "setting_again_czmb",
								title: "充值模版选择(复充)",
								type: "table-select",
								placeholder: "选择",
								action: "admin/pages/kh/yhsj/czmb/getList",
								columns: [{
										"key": "subject",
										"title": "分类",
										"type": "text",
										nameKey: true,
									},
									{
										key: "appname",
										title: "小程序名称",
										type: "text",
										defaultValue: "未绑定"
									},
									{
										key: "nickname",
										title: "代理商昵称",
										type: "text",
										defaultValue: ""
									},
									{
										key: "_id",
										title: "id",
										type: "text",
										idKey: true,
										width: 1
									},
								],
								multiple: false,
								watch: (res) => {
									console.log("res.option", res.option);
									this.form3.data.setting_again_czmb = res.option._id
								}
							},
							{
								"key": "tv_name",
								"title": "剧名",
								"type": "text",
								"disabled": true
							},
							{
								"key": "series",
								"title": "第几集",
								"type": "text",
								"tips": "跳转到哪一集开始播放，一般是第一集"
							},
							{
								key: "appid",
								title: "小程序appid",
								type: "table-select",
								placeholder: "选择",
								action: "admin/pages/kh/xcxpz/xcxgl/getList",
								columns: [{
										key: "appid",
										title: "appid",
										type: "text",
										idKey: true
									},
									{
										key: "appname",
										title: "小程序名字",
										type: "text",
										nameKey: true,
									}
								],
								watch: (res) => {
									this._data.form3.data.appid = res.option.appid;
									this._data.form3.data.appname = res.option.appname;
								}
							},
							{
								key: "appname",
								title: "小程序名字",
								placeholder: "请点击上方选择",
								type: "text",
								disabled: true
							},
							{
								"key": "domain",
								"title": "网页地址",
								"type": "text",
								"disabled": true
							}
						],
						// 表单验证规则
						rules: {
							tv_id: [{
								required: true,
								message: "请选择主剧",
								trigger: ['blur', 'change']
							}],
							series: [{
								required: true,
								message: "请输入集数",
								trigger: ['blur', 'change']
							}],
							appid: [{
								required: true,
								message: "请输入正确的appid,否则跳转会出错",
								trigger: ['blur', 'change']
							}],
						},
						// add 代表添加 update 代表修改
						formType: "",
						// 是否显示表单的弹窗
						show: false
					}
				},
				// 其他弹窗表单
				formDatas: {},
				// 表单相关结束 -----------------------------------------------------------
			};
		},
		// 监听 - 页面每次【加载时】执行(如：前进)
		onLoad(options = {}) {
			console.log("domain", uni.getStorageSync("domain"));
			that = this;
			vk = that.vk;
			that.options = options;
			that.init(options);

			vk.callFunction({
				url: 'admin/pages/kh/yhsj/chudian/fnpath',
				title: '请求中...',
				data: {

				},
				success: (data) => {
					console.log("data=", data);
					let path = data.cloudfunction_path.replace('fc-mp-mp', 'fc-mp');
					this.cloudfunction_path = path;
				}
			});
		},
		// 监听 - 页面【首次渲染完成时】执行。注意如果渲染速度快，会在页面进入动画完成前触发
		onReady() {},
		// 监听 - 页面每次【显示时】执行(如：前进和返回) (页面每次出现在屏幕上都触发，包括从下级页面点返回露出当前页面)
		onShow() {
			let {
				todayStart
			} = vk.pubfn.getCommonTime(new Date());
			this.todayStart = todayStart;
			let user_role = vk.vuex.get('$user.userInfo.role');
			if (user_role.includes("admin")) {
				this.$alert('这是代理商页面，管理员请勿操作。如需添加投放链接，请先创建一个代理商账号，再登录代理商账号进行添加。即将前往【代理商账号】页面', '提示', {
					confirmButtonText: '确定',
					callback: action => {
						uni.navigateTo({
							url: "/pages/admin/dlsgl/agent"
						})
					}
				});
			}
		},
		// 监听 - 页面每次【隐藏时】执行(如：返回)
		onHide() {},
		// 函数
		methods: {
			async change() {
				if (this.value2 == '') {
					return
				}
				let start_time = new Date(this.value2[0]).getTime();
				let end_time = new Date(this.value2[1]).getTime();
				this.get_today_number(start_time, end_time, this.tjsj_item)
			},
			async timechange(e) {
				if (e == "今日数据") {
					let start_time = this.todayStart
					let end_time = this.todayStart + 86400000
					this.get_today_number(start_time, end_time, this.tjsj_item)
					console.log("e==", e);
				}
				if (e == "昨日数据") {
					let start_time = this.todayStart - 86400000
					let end_time = this.todayStart
					this.get_today_number(start_time, end_time, this.tjsj_item)
					console.log("e==", e);
				}
				if (e == "3天总数据") {
					let start_time = this.todayStart - (86400000 * 3)
					let end_time = this.todayStart
					this.get_today_number(start_time, end_time, this.tjsj_item)
					console.log("e==", e);
				}
				if (e == "7天总数据") {
					let start_time = this.todayStart - (86400000 * 7)
					let end_time = this.todayStart
					this.get_today_number(start_time, end_time, this.tjsj_item)
					console.log("e==", e);
				}
				if (e == "15天总数据") {
					let start_time = this.todayStart - (86400000 * 15)
					let end_time = this.todayStart
					this.get_today_number(start_time, end_time, this.tjsj_item)
					console.log("e==", e);
				}
				if (e == "本月") {
					let start_time = vk.pubfn.getCommonTime(new Date()).monthStart
					let end_time = vk.pubfn.getCommonTime(new Date()).monthEnd
					this.get_today_number(start_time, end_time, this.tjsj_item)
					console.log("e==", e);
				}
				if (e == "上个月") {
					let start_time = vk.pubfn.getCommonTime(new Date()).lastMonthStart
					let end_time = vk.pubfn.getCommonTime(new Date()).lastMonthEnd
					console.log(start_time);
					console.log(end_time);
					this.get_today_number(start_time, end_time, this.tjsj_item)
					console.log("e==", e);
				}
			},
			get_today_number(start_time, end_time, item) {
				vk.callFunction({
					url: 'admin/dls/kh/dytflj/tflink_today_data',
					title: '请求中...',
					data: {
						item,
						start_time,
						end_time
					},
					success: (data) => {
						// console.log("data=>", data);
						this.dqzxrs = data.dqzxrs; //当前在线人数
						this.new_add_user = data.num; //新增用户数
						this.new_users_moneysum = vk.pubfn.toDecimal(data
							.new_users_moneysum / 100,
							2); //新用户充值金额
						this.newUsers_payNumber = data.newUsers_payNumber; //新用户充值人数
						this.newUsers_rate = vk.pubfn.toDecimal(data
							.newUsers_payNumber / data.num * 100,
							2); //新用户付费率
						this.newUsers_pcr = vk.pubfn.toDecimal(this
							.new_users_moneysum / data.num,
							2); //新用户人均充值金额
						this.today_Recharge_amount = vk.pubfn.toDecimal(data
							.today_Recharge_amount / 100,
							2); //今日充值金额
						this.today_recharges_Number = data
							.today_recharges_Number; //今日充值笔数
						this.today_unit_price = vk.pubfn.toDecimal(this
							.today_Recharge_amount / this
							.today_recharges_Number, 2) //笔单价
					}
				});
			},
			//保存剧卡点设置
			saveSetting() {
				if (this.setting.tf_start_needpay == "" || this.setting.tf_pay_bean == "") {
					this.$message({
						message: '付费集数或付费豆数不能为空',
						type: 'error'
					});
				} else {
					vk.callFunction({
						url: 'admin/dls/kh/settingTV/add',
						title: '请求中...',
						data: {
							tfid: this.tfid,
							tv_id: this.tv_id,
							tv_name: this.tv_name,
							agent_series: this.setting.tf_start_needpay,
							agent_pay: this.setting.tf_pay_bean,

						},
						success: (data) => {
							this.$message({
								message: '保存成功',
								type: 'success'
							});
						}
					});
				}

			},
			async setCallback(item) {
				// console.log("22222222222222222222222222",item._id);
				let huichuans = await db.collection('a_config').where({
					tfid: item._id
				}).get()
				// console.log("11111111111111111",huichuans.result.data[0]);
				this.huichuan = huichuans.result.data[0]
			},
			// 保存回传比例
			saveRebackPercent() {
				//对提交的字符串去除首尾空格
				if (this.huichuan.douyin_url != '' && this.huichuan.douyin_url != null) {
					this.huichuan.douyin_url = this.huichuan.douyin_url.trim()
				}
				if (this.huichuan.douyin_token != '' && this.huichuan.douyin_token != null) {
					this.huichuan.douyin_token = this.huichuan.douyin_token.trim()
				}
				if (this.huichuan.baidu_token != '' && this.huichuan.baidu_token != null) {
					this.huichuan.baidu_token = this.huichuan.baidu_token.trim()
				}
				if (this.huichuan.oppo_owner_id != '' && this.huichuan.oppo_owner_id != null) {
					this.huichuan.oppo_owner_id = this.huichuan.oppo_owner_id.trim()
				}
				if (this.huichuan.oppo_api_id != '' && this.huichuan.oppo_api_id != null) {
					this.huichuan.oppo_api_id = this.huichuan.oppo_api_id.trim()
				}
				if (this.huichuan.oppo_api_key != '' && this.huichuan.oppo_api_key != null) {
					this.huichuan.oppo_api_key = this.huichuan.oppo_api_key.trim()
				}
				//用户选择循环模式则直接把普通模式回传比例设为100
				if (this.huichuan.douyinRadio == 1) {
					this.huichuan.douyin = 100
				}
				if (this.huichuan.kuaishouRadio == 1) {
					this.huichuan.kuaishou = 100
				}
				if (this.huichuan.tengxunRadio == 1) {
					this.huichuan.tengxun = 100
				}
				if (this.huichuan.ucRadio == 1) {
					this.huichuan.uc = 100
				}
				if (this.huichuan.baiduRadio == 1) {
					this.huichuan.baidu = 100
				}
				if (this.huichuan.oppoRadio == 1) {
					this.huichuan.oppo = 100
				}
				// console.log(this.huichuan);
				vk.callFunction({
					url: 'agent/setting/kh/RebackPercent',
					title: '请求中...',
					data: {
						type: "save",
						tfid: this.tfid,
						huichuan: this.huichuan
					},
					success: (data) => {
						this.$message({
							message: '保存成功',
							type: 'success'
						});
						this.dialogVisible2 = false;
					}
				});

			},
			douyin() {
				let dataurl =
					"/agent/callback/pub/ttcallback?pt=douyin&timestamp=__TS__&ip=__IP__&aid=__AID__&cid=__CID__&advertiser_id=__ADVERTISER_ID__&os=__OS__&ua=__UA__&callback=__CALLBACK_PARAM__&project_id=__PROJECT_ID__&promotion_id=__PROMOTION_ID__&tfid=" +
					this.tfid + "&invite_code=" + this.invite_code;
				this.copy_url("抖音", dataurl)
			},

			kuaishou() {
				let dataurl =
					"/agent/callback/pub/kscallback?pt=kuaishou&timestamp=__TS__&ip=__IP__&aid=__AID__&cid=__CID__&did=__DID__&ua=__UA__&callback=__CALLBACK_PARAM__&tfid=" +
					this.tfid + "&invite_code=" + this.invite_code;
				this.copy_url("快手", dataurl)
			},



			tengxun() {
				let dataurl =
					"/agent/callback/pub/tengxun?pt=tengxun&account_id=__ACCOUNT_ID__&click_id=__CLICK_ID__&click_time=__CLICK_TIME__&device_os_type=__DEVICE_OS_TYPE__&adgroup_id=__ADGROUP_ID__&ad_id=__AD_ID__&ip=__IP__&user_agent=__USER_AGENT__&callback=__CALLBACK__&tfid=" +
					this.tfid + "&invite_code=" + this.invite_code;
				this.copy_url("腾讯(广点通)", dataurl)
			},

			baidu() {
				let dataurl =
					"/agent/callback/pub/baidu?pt=baidu&aid=__IDEA_ID__&pid=__PLAN_ID__&uid=__UNIT_ID__&userid=__USER_ID__&click_id=__CLICK_ID__&ip=__IP__&ua=__UA__&os=__OS__&ts=__TS__&bd_vid=__BD_VID__&bd_vid=__BD_VID__&ext_info=__EXT_INFO__&tfid=" +
					this.tfid + "&invite_code=" + this.invite_code;
				this.copy_url("百度", dataurl)
			},

			copy_url(pt, dataurl) {
				let full_link = this.cloudfunction_path + dataurl
				uni.showModal({
					title: pt + "监测链接如下：",
					content: full_link,
					confirmText: "复制",
					showCancel: false,
					success(res) {
						if (res.confirm) {
							uni.setClipboardData({
								data: full_link,
								success() {
									vk.toast('复制成功');
								}
							})
						}
					}
				})
			},
			handleClose() {
				this.dialogVisible1 = false;
			},
			handleClose2() {
				this.dialogVisible2 = false;
			},
			handleClose3() {
				this.dialogVisible3 = false;
			},
			handleClose4() {
				this.dialogVisible4 = false;
			},
			handleClose5() {
				this.dialogVisible5 = false;
			},
			handleClose6() {
				this.dialogVisible6 = false;
			},
			handleClose9() {
				this.dialogVisible9 = false;
			},
			// 页面数据初始化函数
			init(options) {
				originalForms["form1"] = vk.pubfn.copyObject(that.form1);
			},
			// 页面跳转
			pageTo(path) {
				vk.navigateTo(path);
			},
			// 表单重置
			resetForm() {
				vk.pubfn.resetForm(originalForms, that);
			},
			// 搜索
			search() {
				that.$refs.table1.search();
			},
			// 刷新
			refresh() {
				// location.reload()
				// vk.pubfn.resetForm(originalForms, that);
				that.$refs.table1.refresh();
			},
			// 获取当前选中的行的数据
			getCurrentRow() {
				return that.$refs.table1.getCurrentRow();
			},
			// 监听 - 行的选中高亮事件
			currentChange(val) {
				that.table1.selectItem = val;
			},
			// 当选择项发生变化时会触发该事件
			selectionChange(list) {
				that.table1.multipleSelection = list;
			},
			// 显示添加页面
			addBtn() {
				that.resetForm();
				that.form1.props.action = 'admin/dls/kh/dytflj/add';
				that.form1.props.formType = 'add';
				that.form1.props.title = '添加';
				that.form1.props.show = true;
			},
			// 显示修改页面
			updateBtn({
				item
			}) {
				that.form1.props.action = 'admin/dls/kh/dytflj/update';
				that.form1.props.formType = 'update';
				that.form1.props.title = '编辑';
				that.form1.props.show = true;
				that.form1.data = item;
			},
			// 删除按钮
			deleteBtn({
				item,
				deleteFn
			}) {
				deleteFn({
					action: "admin/dls/kh/dytflj/delete",
					data: {
						_id: item._id
					},
				});
			},
			//批量设置回传方案
			saveBatchupRebackPercent() {

				vk.callFunction({
					url: 'agent/setting/kh/batchup',
					title: '请求中...',
					data: {
						lists: this.table1.multipleSelection,
						huichuan: this.huichuan
					},
					success: (data) => {
						this.huichuan = this.huichuan1
						vk.alert('批量设置完成!');
						this.refresh()
						this.dialogVisible3 = false;

					}
				});
			},
			batchaddBtn() {
				that.resetForm();
				that.form3.props.show = true;
			},
			batchAdd(item) {
				console.log("item==", item);
				if (item.num == 0) {
					vk.alert('必须填写添加数量');
					return;
				}

				if (item.tv_name == "" || item.tv_id == "") {
					vk.alert('必须选择主剧');
					return;
				}

				let backup = item.backup
				let ad_id = item.ad_id
				let appid = item.appid
				let appname = item.appname
				let bind_recharge = item.bind_recharge
				let desc = item.desc
				let domain = item.domain
				let num = item.num
				let recharge_amount = item.recharge_amount
				let setting_czmb = item.setting_czmb
				let setting_again_czmb = item.setting_again_czmb
				let series = item.series
				let tv_id = item.tv_id
				let tv_name = item.tv_name

				for (var i = 0; i < num; i++) {
					setTimeout(() => {
						vk.callFunction({
							url: 'admin/dls/kh/dytflj/add',
							title: '请求中...',
							data: {
								backup,
								ad_id,
								appid,
								appname,
								bind_recharge,
								setting_czmb,
								setting_again_czmb,
								// recharge_amount,
								desc,
								domain,
								series,
								tv_id,
								tv_name
							},
							success: (data) => {

							}
						});
					}, i * 500)

					if ((i + 1) == num) {
						this.form2.props.show = false; //关闭编辑窗口

						setTimeout(() => {
							location.reload()
						}, (i + 2) * 500)
					}
				}
			},
			// 监听 - 批量操作的按钮点击事件
			batchBtn(index) {
				switch (index) {
					case 1:

						this.dialogVisible3 = true;
						this.huichuan = this.huichuan1

						break;
					case 2:
						vk.toast("批量操作按钮2");
						break;
					default:
						break;
				}
			},
			//点击预览回传方案触发函数
			preview(item) {
				vk.callFunction({
					url: 'admin/dls/kh/dytflj/preview',
					title: '请求中...',
					data: {
						backup: item.backup
					},
					success: (data) => {
						this.form2.data = data.rows[0];
						this.form2.props.show = true;
					}
				});
			}
		},
		// 监听属性
		watch: {

		},
		// 过滤器
		filters: {

		},
		// 计算属性
		computed: {

		}
	};
</script>
<style lang="scss" scoped>
	.page-body {}


	.topbox {
		width: 23%;
		height: 90px;
		display: flex;
		flex-direction: column;
		justify-content: space-evenly;
		/* box-shadow: 0 4rpx 8rpx 0 rgba(0, 0, 0, 0.2), 0 6rpx 20rpx 0 rgba(0, 0, 0, 0); */
		margin: 20px 20px 0rpx 0;
		padding: 15px 30px;
		border-radius: 10rpx;
		background-color: #fff;
	}

	.box2 {
		width: 95%;
		display: flex;
		flex-wrap: wrap;
		box-shadow: 0 4rpx 8rpx 0 rgba(0, 0, 0, 0.2), 0 6rpx 20rpx 0 rgba(0, 0, 0, 0);
		margin: 20rpx;
		padding: 20rpx;
		border-radius: 20rpx;
	}

	.numstyle {
		color: #4c4c4c;
		font-size: larger;
		/* font-weight: bold; */
	}

	/* 请根据实际需求修改父元素尺寸，组件自动识别宽高 */
	.charts-box {
		width: 100%;
		height: 450px;
	}

	.boxTemplate {
		width: 730rpx;
		margin: 0 auto;
		display: flex;
		flex-wrap: wrap;

		.Scheme {
			width: 350rpx;
			height: 180rpx;
			margin: 20rpx 0;

			.Schemecontent {
				width: 94%;
				height: 180rpx;
				border-radius: 12rpx;
				margin: 0 auto;
				position: relative;
				background-image: url('@/static/tehui.png');
				background-size: 100% 180rpx;

				view {
					position: absolute;
				}

				.Judge {
					padding: 0px 40rpx;
					text-align: center;
					color: #e5563b;
					background-image: url('@/static/tehuis.png');
					background-size: 100% 100%;
					border-radius: 12rpx 0 12rpx 0;
					font-size: 26rpx;
					font-weight: 600;
				}

				.RechargeAmount {
					font-weight: 600;
					font-size: 36rpx;
					left: 5%;
					top: 25%;
				}

				.GiveBean {
					padding: 0 20rpx;
					font-size: 24rpx;
					font-weight: 600;
					background-color: #f55125;
					color: #fff;
					border-radius: 50rpx;
					left: 40%;
					top: 29%;
				}

				.RechargeText {
					font-size: 26rpx;
					font-weight: 600;
					left: 8%;
					width: 91%;
					top: 50%;
				}

				.PercentageUser {
					color: #e37f75;
					font-size: 24rpx;
					font-weight: 600;
					right: 20rpx;
					bottom: 10rpx;
				}
			}

			.Schemecontents {
				width: 94%;
				height: 180rpx;
				border-radius: 12rpx;
				margin: 0 auto;
				background-color: #ffead8;
				position: relative;

				view {
					position: absolute;
				}

				.RechargeAmount {
					font-weight: 600;
					font-size: 36rpx;
					left: 3%;
					top: 20%;
				}

				.GiveBean {
					padding: 0rpx 20rpx;
					font-size: 24rpx;
					font-weight: 600;
					background-color: #f55125;
					color: #fff;
					border-radius: 50rpx;
					left: 38%;
					top: 24%;
				}

				.RechargeText {
					font-size: 24rpx;
					font-weight: 600;
					left: 5%;
					bottom: 20%;
				}
			}

			.Schemecontentss {
				width: 94%;
				height: 180rpx;
				border-radius: 14rpx;
				margin: 0 auto;
				position: relative;
				background-image: url('@/static/huiyuan.png');
				background-size: 100% 180rpx;

				view {
					position: absolute;
				}

				.Judge {
					padding: 0px 40rpx;
					text-align: center;
					color: #e5563b;
					background-color: #fafc43;
					border-radius: 12rpx 0 12rpx 0;
					font-size: 26rpx;
					font-weight: 600;
				}

				.RechargeAmount {
					color: #ffffff;
					font-weight: 600;
					font-size: 32rpx;
					left: 5%;
					top: 25%;
				}

				.RechargeText {
					color: #f2e4d8;
					font-size: 26rpx;
					font-weight: 500;
					left: 5%;
					width: 91%;
					top: 52%;
				}
			}
		}
	}
</style>